def pr(x):
    for i in range(2,int(x**0.5)+1):
        if x % i == 0:
            return False
            break
    return True


prime = []
for x in range(100,1000):
    if pr(x):
        prime.append(x)
# print(prime)

s = input()
s = s.replace('zero','0').replace('one','1').replace('two','2').replace('three','3').replace('four','4').replace('five','5')
s = s.replace('six','6').replace('seven','7').replace('eight','8').replace('nine','9')
while ' ' in s:
    s = s.replace(' ','')
if len(s) == 3 and s[0] != '0':
    x = int(s)
    x1 = 101
    x2 = 997
    for i in range(len(prime)):
        if x == prime[i]:
            res = x
        elif x > prime[i]:
            x1 = prime[i]
            res = x1
        else:
            x2 = prime[i]
            if abs(x2 - x) < abs(x - x1):
                res = x2
            else:
                res = x1
            break
    print(res)
   
else: print('Wrong input')
